#
# @lc app=leetcode.cn id=90 lang=python3
#
# [90] 子集 II
#

# @lc code=start
from typing import List
import itertools
class Solution:
    def subsetsWithDup(self, nums: List[int]) -> List[List[int]]:
        res=[[]]
        nums.sort() #关键行
        for i in range(1, len(nums)+1):
            iter1 = list(set(itertools.combinations(nums, i)))
            res=res+list(iter1)
        return res

# @lc code=end

if __name__ == '__main__':
    solution = Solution()
    nums = [5, 5, 5, 5, 5]
    print(solution.subsetsWithDup(nums))